//
//  HCFindButtonsView.m
//  Aierle
//
//  Created by jiayibai-02por on 2017/6/1.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCFindButtonsView.h"
#import "HCFindCustomButton.h"

@implementation HCFindButtonsView

- (instancetype)initWithFrame:(CGRect)frame {

    if (self = [super initWithFrame:frame]) {
        
        [self initSubviews];
    }
    return self;
}

//初始化界面
- (void)initSubviews {

    self.backgroundColor = [UIColor whiteColor];
    NSArray *names = [NSArray arrayWithObjects:@"积分商城",@"门店热榜",@"店家推荐",@"更多信息", nil];
    NSArray *images = [NSArray arrayWithObjects:@"happy_find_scoreStore",@"happy_findstore",@"happy_findStar",@"happy_hotStore", nil];

    CGFloat betweenWidth = (Screen_width-YBKAdaptiveW(60)*4)/4.0;
    for (int i = 0; i < 4; i++) {
        
        HCFindCustomButton *button = [[HCFindCustomButton alloc] initWithFrame:CGRectMake(betweenWidth/2.0 + (YBKAdaptiveW(60)+betweenWidth)*i, (YBKAdaptiveH(90)-YBKAdaptiveH(60))/2.0, YBKAdaptiveW(60), YBKAdaptiveH(60))];
        button.tag = 10 + i;
        button.nameLabel.text = names[i];
        button.buttonImage.image = [UIImage imageNamed:images[i]];
        [button addTarget:self action:@selector(buttonClickAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
}

- (void)buttonClickAction:(HCFindCustomButton *)sender {

    NSInteger index = sender.tag-10;
    if (self.clickFourButtonBlock) {
        
        self.clickFourButtonBlock(index);
    }
}

@end
